<template>
  <div class="container">
    <div class="title">热门搜索</div>
    <div class="box">
      <div class="item" v-for="(v, k) in tag.allTag" :key="k" @click="toTag(v)">
        <img :src="getImg(k + 1)" alt="" />
        <div class="name">{{ v.ThemeName }}</div>
        <div class="mask"></div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import {
  toRefs,
  reactive,
  onMounted,
  ref,
  watch,
  nextTick,
  onActivated,
  inject,
} from "vue";
import * as HomeApi from "@/api/home";
import { useRouter } from "vue-router";
// import bus from "@/utils/bus";
export default {
  name: "",
  setup() {
    const router = useRouter();
    const tag = inject("tags");
    const getImg = (v) => {
      return new URL(`/src/assets/tags/${v}.png`, import.meta.url).href;
    };
    const toTag = (v) => {
      // bus.$emit("changeTheme", vThemeName);
      router.push("/index?themeName=" + v.ThemeName + "&themeId=" + v.ThemeID);
    };
    return {
      tag,
      getImg,
      toTag,
    };
  },
};
</script>
<style scoped lang="scss">
.title {
  font-weight: 600;
  font-size: 33px;
  line-height: 40px;
  letter-spacing: -0.02em;
  text-align: center;
}
.container {
  width: 74%;
  margin: 0 auto;
}
.box {
  display: flex;
  margin-top: 20px;
  justify-content: space-between;
  .item {
    width: 16%;
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
    cursor: pointer;
    img {
      width: 100%;
      // object-fit: cover;
      height: 100%;
    }
    &:hover {
      .mask {
        display: block;
      }
    }
    .mask {
      display: none;
      transition: 0.5s all;
      position: absolute;
      width: 100%;
      height: 100%;
      left: 0;
      top: 0;
      background: rgba(0, 0, 0, 0.5);
    }
    .name {
      color: #fff;
      font-size: 30px;
      font-weight: 600;
      position: absolute;
      left: 50%;
      z-index: 999;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  }
  flex-wrap: wrap;
  &::after {
    content: "";
    // flex:1;
    margin-bottom: 20px;
    width: 16%;
    // flex: 999;
  }
}
</style>
